package com.chencong.online.function;

import com.chencong.online.bean.WebLogEventBean;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @program: user-behavior-analysis-online
 * @ClassName HotPageCountAggFunc
 * @description:热门页面浏览聚合统计(累加器)
 * @author: chencong
 * @create: 2021-12-23 11:03
 **/
public class PageCountAggFunc implements AggregateFunction<WebLogEventBean, Long, Long> {
    @Override
    public Long createAccumulator() {
        return 0L;
    }

    @Override
    public Long add(WebLogEventBean value, Long accumulator) {
        return accumulator + 1;
    }

    @Override
    public Long getResult(Long accumulator) {
        return accumulator;
    }

    @Override
    public Long merge(Long a, Long b) {
        return a + b;
    }
}
